<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>快排</title>
    <script>
        var arrs =[1,3,45,2,3,4,2,44,5,34,54,3,4,2,4,76,3,4];
        var arrs2 =[1,3,45,2,3,4,2,44,5,34,54,3,4,2,4,76,3,4,0,1,-14,99,1,1,99,99];

        function fastNum(arr) {
            if ((arr.length<=1) || arr.reduce((a,b) => a+b,0) === arr.length*arr[0]){

                return  arr;
            }
            var num=arr[0];
            var num_left=[];
            var num_right=[];
            var num_center=[num];
            for (i=1;i<arr.length;i++){
                if (arr[i]<num){
                    num_left.push(arr[i]);
                }else if(arr[i]>num){
                    num_right.push(arr[i]);
                }else if(arr[i]===num){
                    num_center.push(num);
                }
            }
            // var newNumber =num_left.concat(num_center,num_right);
            // return newNumber;
            return fastNum(num_left).concat(fastNum(num_center),fastNum(num_right))
        }

        console.log(fastNum(arrs).join());
    </script>
</head>
<body>

</body>
</html>